package net.common.service;

/**
 * 分页BEAN
 * 
 * @author 孙树林
 * 
 */
public class PageBean {

	private int totalPage;
	private int currentPage = 1;
	private int currentRec = 2;
	private int totalRec;
	private int first = 1;
	private int last;
	private int pre;
	private int next;

	public int getStartRow() {
		return (currentPage - 1) * currentRec;
	}

	public int getEndRow() {
		return getStartRow() + currentRec;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getCurrentRec() {
		return currentRec;
	}

	public void setCurrentRec(int currentRec) {
		this.currentRec = currentRec;
	}

	public int getTotalRec() {
		return totalRec;
	}

	public void setTotalRec(int totalRec) {
		this.totalRec = totalRec;
		if(totalRec % currentRec == 0) {
			totalPage = totalRec / currentRec;
		} else {
			totalPage = totalRec / currentRec + 1;
		}
		if(currentPage == 1) {
			pre = 1;
		} else {
			pre = currentPage - 1;
		}
		if(currentPage == totalPage) {
			next = currentPage;
		} else {
			next = currentPage + 1;
		}
		last = totalPage;
	}

	public int getFirst() {
		return first;
	}

	public void setFirst(int first) {
		this.first = first;
	}

	public int getLast() {
		return last;
	}

	public void setLast(int last) {
		this.last = last;
	}

	public int getPre() {
		return pre;
	}

	public void setPre(int pre) {
		this.pre = pre;
	}

	public int getNext() {
		return next;
	}

	public void setNext(int next) {
		this.next = next;
	}
}
